/*
 * ��EMH����ⲿ��ȡҳ�޸Ĳ���
 */
function DocmentCanModify()
{
	return true;
};
/*
 * ��EMH����ⲿ��ȡҳ���
 */
function GetPageDocment()
{
	var objtext=new Array();
	
	if($.emhbaseobject!=null)
	{
		$("[emhvalue]").each(
				function(index,obj)
				{
					var ctrl=$.emhbaseobject.GetObject($(obj));
					if(ctrl!=null)
					{
						var ret={};
						ret.NAME=ctrl.GetInfo(1);
						ret.TEXT=ctrl.GetValue();
						objtext.push(ret);
					}
				}
			);
	}
	
	var objret=new Array();
	var objdoc=$("#EMH_ENVIRONMENTT_DOCMENT").data("$EMHDATA$");
	if((objdoc!=null)&&(objdoc.length>0))
	{
		$.each(
			objdoc,
			function(ii,jsonobj)
			{
				EMHEventObject.SetTempData(objret,jsonobj.NAME,jsonobj.TEXT);
			});
	}
	EMHEventObject.SetTempData(objret,"$CONTENT$",JSON.stringify(objtext));
	return objret;
};

/*
 * EMH����������
 */
var EMHArrayObject=
{	
	forEach	: function(ee,callback)
	{
		var ii=0;
		for(ii=0;ii<ee.length;ii++)
		{
			callback(ee[ii]);
		}
	},
	
	createNew: function(col)  //�������
	{
		var obj={};
		obj.head=new Array((col>0)?col:1);
		obj.arraydata=new Array();
		
		obj.GetArrayRow=function(row)
		{
			var ret="";
			if((this.arraydata.length>=row)&&(row>0))
				ret=this.arraydata[row-1].join("/");
			return ret;
		};

		obj.InsArrayRow=function(row,data)
		{
			var retobj;
			retobj=new Array();
			forEach
			(
				data.split("/"),
				function(e)
				{
					retobj.push(e);
				}
			);
			
			if((this.arraydata.length>=row)&&(row>0))
				this.arraydata.splice(row-1,0,retobj);
			else
				this.arraydata.push(retobj);
		};

		obj.DelArrayRow=function(row)
		{
			if((this.arraydata.length>=row)&&(row>0))
				this.arraydata.splice(row-1,1);
		};

		obj.FindArrayRow=function(col,text)
		{
			var rownum=0,ret=-1;
			forEach
			(
				this.arraydata,
				function(ee)
				{
					if(ee[col-1]==text)
						ret=rownum+1;
					rownum=rownum+1;
				}
			);
			return ret;
		};

		obj.GetArrayCell=function(row,col)
		{
			if((row>0)&&(row<=this.arraydata.length))
				return this.arraydata[row-1][col-1];
			return "";
		};

		obj.SetArrayCell=function(row,col,text)
		{
			while(row>this.arraydata.length)
				this.arraydata.push(new Array());
			rowobj=this.arraydata[row-1];
			while(col>rowobj.length)
				rowobj.push("");
			this.arraydata[row-1][col-1]=text;
		};

		obj.ArrayFromValue=function(valuename)
		{
			
		};

		obj.ArrayToValue=function(valuename)
		{

		};

		obj.ArrayFromText=function(text)
		{

		};

		obj.ArrayToText=function()
		{

		};

		obj.GetArrayRows=function()
		{
			return this.arraydata.length;
		};
		return obj;
	}		
};
/*
 * EMH�¼�����������
 * http://127.0.0.1:9090/emh/emhHtmlAction.do
 */
var EMHEventObject=
{	
	HttpPostData:function(lpurl,lpdata) 
	{
		var ret="";
		var rettotle=0;
		while(ret.length==0)
		{
			$.ajax({
			  	url:lpurl,
				type:"POST",
			  	async:false,
			  	dataType:"xml",
				crossDomain:true,
				data:lpdata,
			  	success:function(rettext)
				{
			  		var xmiobj=$(rettext);
			  		if((xmiobj!=null)&&(xmiobj.length>0))
			  			ret=xmiobj;
				}
			});
			rettotle+=1;
			if(rettotle>2)
				break;
		}
		return ret;
	},
	
	GetPostText:function() 
	{
		var postobj={};
		postobj.DATA="";
		postobj.DIRPATH="";
		postobj.DOCMENT="";
		
		var objret=$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$");
		if(objret!=null)
			postobj.DATA=objret;
		return "$EMHPOSTFORBASE64$=<UTF-8>"+encodeURIComponent($.base64.btoa(JSON.stringify(postobj)));
	},
	
	GetPostDocment:function(doc) 
	{
		var postobj={};
		postobj.DATA="";
		postobj.DIRPATH="";
		postobj.DOCMENT="";
		if(doc!=null)
			postobj.DOCMENT=doc;
		
		var objret=$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$");
		if(objret!=null)
			postobj.DATA=objret;
		return "$EMHPOSTFORBASE64$=<UTF-8>"+encodeURIComponent($.base64.btoa(JSON.stringify(postobj)));
	},
	
	PassTextPara:function(text){
		var objret=$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$");
		if(objret!=null)
		{
			var xmlobj=$(text);
			if(xmlobj.length>0)
			{
				xmlobj.find("VALUE").each(
					function(index, ele)
					{
						EMHEventObject.SetTempData(objret,$(ele).find("NAME").text(),$(ele).find("TEXT").text());
					});
			};
		};
	},
	
	AddPostPara:function(key,value) 
	{
		var objret;
		objret=$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$");
		if(objret!=null)
			EMHEventObject.SetTempData(objret,key,value);
	},
	
	DelPostPara:function(key,value) 
	{
		var ii;
		var objret=$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$");
		if(objret!=null){
			for(ii=0;ii<objret.length;ii++){
				if(objret[ii].NAME==key){
					objret.splice(ii,1);
					$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$",objret);
					return;
				};
			};
		};
	},
	 //���url�����keystrid
	PassHttpsUrl:function(url)
	{
		var paraObj;
		paraObj=$("#EMH_ENVIRONMENTT_TEMP");
		paraObj.removeData("$EMHPOST$");
	
		var objret=new Array();
		var objdoc=$("#EMH_ENVIRONMENTT_DOCMENT").data("$EMHDATA$");
		if((objdoc!=null)&&(objdoc.length>0))
		{
			$.each(
				objdoc,
				function(valuename,valuetext)
				{
					EMHEventObject.SetTempData(objret,valuename,valuetext);
				});
		}
		urls = url.split("?");
		if(urls.length==2)
		{
			var ii;
			paras = urls[1].split("&"); 
		    for(ii=0;ii<paras.length;ii++)
		    {
		    	keyvalues = paras[ii].split("="); 
		        if(keyvalues.length==2)
		        	EMHEventObject.SetTempData(objret,keyvalues[0],decodeURIComponent(keyvalues[1]));
		    };
		}
		$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$",objret);
		EMHEventObject.DelPostPara("LOGINKEY");
	    
		eniv=$("#EMH_ENVIRONMENTT_INFO");
		if(urls[0].toLocaleLowerCase().indexOf("http://")!=0)
		{
			if(urls[0].toLocaleLowerCase().indexOf("https://")!=0)
			{
				tmp=eniv.attr("data-ip");
				if(tmp!=null)
				{
					tmp=eniv.attr("data-HTTPSPORT");
					if(tmp!=null)
					{
						url="https://"+eniv.attr("data-IP");
						url=url+":"+tmp;
					}
					else
					{
						url="http://"+eniv.attr("data-IP");
						tmp=eniv.attr("data-PORT");
						if(tmp!=null)
							url=url+":"+tmp;
					}
				}
				else
					url="";
				if(!(urls[0].indexOf("/")>0))
				{
					tmp=eniv.attr("data-PROJECT");
					if((tmp==null)||(tmp.length==0))
						tmp="emh";
					url=url+"/"+tmp;
				}
				if(urls[0].indexOf("/")==0)
					url=url+urls[0];
				else
					url=url+"/"+urls[0];
			}
		}
		else
			url=urls[0];
		
		tmp=eniv.attr("data-LOGINKEY");
		if((tmp!=null)&&(tmp.length>0))
		{
			url+="?LOGINKEY=";
			url+=encodeURIComponent(tmp);
		}
		return url;
	},
	PassHttpUrl:function(url)
	{
		var paraObj;
		paraObj=$("#EMH_ENVIRONMENTT_TEMP");
		paraObj.removeData("$EMHPOST$");
	
		var objret=new Array();
		var objdoc=$("#EMH_ENVIRONMENTT_DOCMENT").data("$EMHDATA$");
		if((objdoc!=null)&&(objdoc.length>0))
		{
			$.each(
				objdoc,
				function(valuename,valuetext)
				{
					EMHEventObject.SetTempData(objret,valuename,valuetext);
				});
		}
		urls = url.split("?");
		if(urls.length==2)
		{
			var ii;
			paras = urls[1].split("&"); 
		    for(ii=0;ii<paras.length;ii++)
		    {
		    	keyvalues = paras[ii].split("="); 
		        if(keyvalues.length==2)
		        	EMHEventObject.SetTempData(objret,keyvalues[0],decodeURIComponent(keyvalues[1]));
		    };
		}
		$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$",objret);
		EMHEventObject.DelPostPara("LOGINKEY");
	    
		eniv=$("#EMH_ENVIRONMENTT_INFO");
		if(urls[0].toLocaleLowerCase().indexOf("http://")!=0)
		{
			if(urls[0].toLocaleLowerCase().indexOf("https://")!=0)
			{
				tmp=eniv.attr("data-ip");
				if(tmp!=null)
				{
					url="http://"+tmp;
					tmp=eniv.attr("data-PORT");
					if(tmp!=null)
						url=url+":"+tmp;
				}
				else
					url="";
				if(!(urls[0].indexOf("/")>0))
				{
					tmp=eniv.attr("data-PROJECT");
					if((tmp==null)||(tmp.length==0))
						tmp="emh";
					url=url+"/"+tmp;
				}
				if(urls[0].indexOf("/")==0)
					url=url+urls[0];
				else
					url=url+"/"+urls[0];
			}
		}
		else
			url=urls[0];
		
		tmp=eniv.attr("data-LOGINKEY");
		if((tmp!=null)&&(tmp.length>0))
		{
			url+="?LOGINKEY=";
			url+=encodeURIComponent(tmp);
		}
		return url;
	},
	SetTempData : function(eniv,key,value) 
	{
		var ii;
		for(ii=0;ii<eniv.length;ii++)
		{
			if(eniv[ii].NAME==key)
			{
				eniv[ii].TEXT=value;
				return ;
			}
		}
		var dd={};
        dd.NAME=key;
        dd.TEXT=value;
        eniv.push(dd);
	},
	
	GetTempData : function(eniv,key) 
	{
		var ii;
		for(ii=0;ii<eniv.length;ii++)
		{
			if(eniv[ii].NAME==key)
				return eniv[ii].TEXT;
		}
		return "";
	},
	
	Login : function(userid,password,url)
	{
		var ret=false;
		url=EMHEventObject.PassHttpsUrl(url);
		
		var objret=$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$");
		if(objret==null)
			objret=new Array();
		
		EMHEventObject.SetTempData(objret,"loginId",userid);
		EMHEventObject.SetTempData(objret,"password",password);
		
		$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$",objret);

  		var loginobj=$(EMHEventObject.HttpPostData(url,EMHEventObject.GetPostText()));
  		if((loginobj!=null)&&(loginobj.length>0))
  		{
  			var tmp=loginobj.find("CODE").text();
  			if(tmp=="LOGIN")
			{
				var keystr="";
  				var obj1=loginobj.find("PARA");
  				if((obj1!=null)&&(obj1.length>0))
				{
	  				obj1=obj1.find("LOGIN");
	  				if((obj1!=null)&&(obj1.length>0))
	  					keystr=obj1.find("KEYSTR").text();
				}
  				$("#EMH_ENVIRONMENTT_INFO").attr("data-LOGINKEY",keystr);
  				ret=true;
			}
  			else
  			if(tmp=="ERROR")
			{
  				if($.errorout!=null)
				{
  	  				var obj1=loginobj.find("PARA");
  	  				if((obj1!=null)&&(obj1.length>0))
  					{
  		  				obj1=obj1.find("ERROR");
  		  				if(obj1!=null)
  		  					$.errorout(obj1.text());
  					}
				}
			}
  		}
		return ret;
	},
	
    ChangePassword : function(userid,password,newpwd,url)
    {
        var ret=false;
        url=EMHEventObject.PassHttpsUrl(url);
        
        var objret=$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$");
        if(objret==null)
            objret=new Array();
        
        EMHEventObject.SetTempData(objret,"loginId",userid);
        EMHEventObject.SetTempData(objret,"password",password);
        
        $("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$",objret);

        var loginobj=$(EMHEventObject.HttpPostData(url,EMHEventObject.GetPostText()));
        if((loginobj!=null)&&(loginobj.length>0))
        {
            var tmp=loginobj.find("CODE").text();
            if(tmp=="LOGIN")
            {
                var keystr="";
                var obj1=loginobj.find("PARA");
                if((obj1!=null)&&(obj1.length>0))
                {
                    obj1=obj1.find("LOGIN");
                    if((obj1!=null)&&(obj1.length>0))
                        keystr=obj1.find("KEYSTR").text();
                }
                $("#EMH_ENVIRONMENTT_INFO").attr("data-LOGINKEY",keystr);
                ret=true;
            }
            else
            if(tmp=="ERROR")
            {
                if($.errorout!=null)
                {
                    var obj1=loginobj.find("PARA");
                    if((obj1!=null)&&(obj1.length>0))
                    {
                        obj1=obj1.find("ERROR");
                        if(obj1!=null)
                            $.errorout(obj1.text());
                    }
                }
            }
        }
        return ret;
    },

	InitObject: function() 
	{
	},
	//�������
	createNew: function(ctrl)
	{
		var obj={};
		if(ctrl!=null)
		{
			obj.valuename=$(ctrl).attr("emhvalue");
			obj.id=$(ctrl).attr("id");
		}
		else
		{
			obj.valuename="";
			obj.id="";
		}
		//Ϊ���ݱ��������빦�ܿ�
		obj.DebugMessage=function(message)
		{
			console.log(message);
		};
		obj.CreatePage=function(lpname,ww,hh){};
		obj.CreateBox=function(lppage,lpname,hh,ss){};
		obj.CreateItem=function(lppage,lpbox,lpname,ll,tt,ww,hh,ss){};
		obj.OpenPYLayout=function(operate,name,url){};
		obj.PrintDoc=function(name,startpage,direct){};
		obj.CreateMenu=function(name,lptext){};
		obj.RunCommand=function(path){};
		obj.SelectIME=function(name){};
		obj.CreatePopupWindow=function(title,style,url){};
		obj.ClosePopupWindow=function(){};
		obj.SetWindowPos=function(xx,yy){};
		obj.SM_SetWindowSize=function(ww,hh){};
		obj.HIWORD=function(dd){};
		obj.LOWORD=function(dd){};
		obj.atoiStr=function(dd){};
		obj.itoaStr=function(dd){};
		//-----------------
		obj.GetValue=function(nn)
		{ 
			return $("#EMH_ENVIRONMENTT_VALUELIST").data(nn);
		};
		
		obj.SetValue=function(nn,dd)
		{ 
			$("#EMH_ENVIRONMENTT_VALUELIS").data(nn,dd);
		};
		
		obj.SetItemInfo=function(lppage,lpbox,lpname,ii,lpinfo)
		{
			if($.emhbaseobject==null)
				return ;
			if(ii!=null)
			{
				var obj=$.emhbaseobject.FindObject(lppage,lpbox,lpname);
				if(obj!=null)
					obj.SetInfo(ii,lpinfo);
			}
			else
			{
				$("[emhvalue='"+lppage+"']").each
				(
					function(index,obj)
					{
						var ctrl=$.emhbaseobject.GetObject($(obj));
						if(ctrl!=null)
							ctrl.SetInfo(lpbox,lpname);
					}
				);
			}
		};
		
		obj.GetItemInfo=function(lppage,lpbox,lpname,ii)
		{
			if($.emhbaseobject==null)
				return "";
			if(ii!=null)
			{
				var obj=$.emhbaseobject.FindObject(lppage,lpbox,lpname);
				if(obj!=null)
					return obj.GetInfo(ii);
			}
			else
			{
				var retvalue="";
				$("[emhvalue='"+lppage+"']").each
				(
					function(index,obj)
					{
						var ctrl=$.emhbaseobject.GetObject($(obj));
						if(ctrl!=null)
							retvalue=ctrl.GetInfo(lpbox);
					}
				);
				return retvalue;
			}
			return "";
		};
		
		obj.SetJavaValue=function(lpname,lpinfo)
		{
			if($.emhbaseobject==null)
				return ;
			$("[emhvalue='"+lpname+"']").each
			(
				function(index,obj)
				{
					var ctrl=$.emhbaseobject.GetObject($(obj));
					if(ctrl!=null)
						ctrl.SetValue(lpinfo);
				}
			);
		};
		
		obj.GetJavaValue=function(lpname)
		{
			if($.emhbaseobject==null)
				return "";
			
			var objret=$("[emhvalue='"+lpname+"']").first();
			if(objret!=null)
			{
				var ctrl=$.emhbaseobject.GetObject($(objret));
				if(ctrl!=null)
					return ctrl.GetValue();
			}
			return "";
		};
		
		obj.RunUrl=function(IP,URL,DATA)
		{
			if(IP!="")
			{
				if(IP.substr(0,1)=="/")
					URL="http://"+IP+URL;
				else
					URL="http://"+IP+"/"+URL;
			}
			URL=EMHEventObject.PassHttpUrl(URL);
			if(DATA.length>0)
				EMHEventObject.PassTextPara(DATA);
			return EMHEventObject.HttpPostData(URL, EMHEventObject.GetPostText());
		};
		
		obj.PassReturn=function(rettext,type,para)
		{
	  		var xmiobj=$(rettext);
	  		if(xmiobj!=null)
  			{
	 			var Code=xmiobj.find("CODE").text();
				if(Code=="SUBDIR")	//�²�Ŀ¼
				{
				}
				else
				if(Code=="GOTO")	//ת������Ŀ¼
				{
				}
				else
				if(Code=="PARENT")	//�ϲ�Ŀ¼
				{
				
				}
				else
				if(Code=="UPDATE")	//ˢ��
				{
				
				}
				else
				if(Code=="JAVASCRIPT")	//ִ��JAVA����
				{
				
				}
				else
				if(Code=="PRINT")	//��ӡ
				{
				}
				else
				if(Code=="POPUP")	//���ڱ���@@���Ͷ���@@ҳ��ʾĿ¼
				{
				}
				else
				if(Code=="MSGBOX")	//�����Ϣ ����@@��Ϣ����@@��ť
				{
				}
				else
				if(Code=="EVENT")	//�򸸴��������Ϣ
				{
				}
				else
				if((type!=null)&&(type!=""))
				{
					if(type==Code)
					{
						var para=xmiobj.find("PARA");
						if(para.children().length>0)
							return "<root>"+para.html()+"</root>";
						else
							return para.text();
					}
				}
  			}
			return "";
		};
		
		obj.SetTimerEvent=function(valuename,interval)
		{
			return "";
		};

		obj.SaveDoc=function(IP,URL,PORT)
		{
			return ;
		};

		obj.Login=function(userid,password,url)
		{
			return EMHEventObject.Login(userid, password, url);
		};

		obj.Logout=function(url)
		{
			return ;
		};

		obj.ClearDoc=function()
		{
			if($.emhbaseobject==null)
				return ;
			$("[emhvalu]").each(
				function(index,obj)
				{
					ctrl=$.emhbaseobject.GetObject($(obj));
					if(ctrl!=null)
						ctrl.Clear();
				});
		};

		obj.UpdatePage=function()
		{
			var lpurl=window.location.href;
			lpurl=EMHEventObject.PassHttpUrl(lpurl);
			var objret=$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$");
			if(objret!=null)
			{
				var tmp=EMHEventObject.GetTempData(objret, "DIR");
				if((tmp!=null)&&(tmp.length>0))
				{
					if(lpurl.indexOf("?")>0)
						lpurl+=("&DIR="+encodeURIComponent(tmp));
					else
						lpurl+=("?DIR="+encodeURIComponent(tmp));
				}
			}
			$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$",null);
			location.replace(lpurl);
			return ;
		};

		obj.GotoParent=function()
		{
			var lpurl=window.location.href;
			lpurl=EMHEventObject.PassHttpUrl(lpurl);
			
			var lpdir=$("#EMH_ENVIRONMENTT_INFO").attr("data-DIR");
			if((lpdir!=null)&&(lpdir.length>0))
			{
				var ss = urls[1].split("/"); 
				if(ss!=null)
				{
					var ii;
					var path="";
					for(ii=0;ii<(ss.length-1);ii++)
					{
						if(path.length>0)
							path+=("/"+ss[ii]);
						else
							path+=ss[ii];
					}
					if(lpurl.indexOf("?")>0)
						lpurl+=("&DIR="+encodeURIComponent(tmp));
					else
						lpurl+=("?DIR="+encodeURIComponent(tmp));
				}
			}
			
			$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$",null);
			location.replace(lpurl);
			return ;
		};

		obj.GotoSubdir=function(subdir)
		{
			if(!((subdir!=null)&&(subdir.length>0)))
				return "";
			
			var lpurl=window.location.href;
			lpurl=EMHEventObject.PassHttpUrl(lpurl);
			
			var lpdir=$("#EMH_ENVIRONMENTT_INFO").attr("data-DIR");
			if(!((lpdir!=null)&&(lpdir.length>0)))
				lpdir="";
			if(lpdir=="ROOT")
				lpdir="";
			
			if(lpdir.length>0)
				lpdir+=("/"+subdir);
			else
				lpdir=subdir;

			if(lpurl.indexOf("?")>0)
				lpurl+=("&DIR="+encodeURIComponent(lpdir));
			else
				lpurl+=("?DIR="+encodeURIComponent(lpdir));
			
			$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$",null);
			location.replace(lpurl);
			return ;
		};

		obj.GotoDir=function(path)
		{
			if(!((path!=null)&&(path.length>0)))
				path="";
			
			var lpurl=window.location.href;
			lpurl=EMHEventObject.PassHttpUrl(lpurl);
			
			var lpdir=$("#EMH_ENVIRONMENTT_INFO").attr("data-DIR");
			if(!((lpdir!=null)&&(lpdir.length>0)))
				lpdir="";
			if(lpdir=="ROOT")
				lpdir="";
			
			if(path.length>0)
			{
				if(lpdir.length>0)
					lpdir+=("/"+path);
				else
					lpdir=path;
			}

			if(lpurl.indexOf("?")>0)
				lpurl+=("&DIR="+encodeURIComponent(lpdir));
			else
				lpurl+=("?DIR="+encodeURIComponent(lpdir));
			
			$("#EMH_ENVIRONMENTT_TEMP").data("$EMHPOST$",null);
			location.replace(lpurl);
			return ;
		};

		obj.CopyText=function(text)
		{
			return ;
		};

		obj.SetText=function(text)
		{
			if($.emhbaseobject==null)
				return ;
			var dd=$.parseJSON(text);
			if(dd!=null)
				$.each(dd,function(valuename,valuetext)
				{
					$("[emhvalue='"+valuename+"']").each(
					function(index,obj)
					{
						var ctrl=$.emhbaseobject.GetObject($(obj));
						if(ctrl!=null)
							ctrl.SetValue(valuetext);
					});
				});
		};

		obj.GetText=function()
		{
			return JSON.stringify(GetPageDocment());
		};

		obj.RunJS=function(jstext)
		{
			return ;
		};


		// ����ĳЩ�?�����û�����ͨ���ά�������佻�����
		obj.NewArray=function(name,col)
		{
			$("#EMH_ENVIRONMENTT_ARRAY").data(name,EMHArrayObject.createNew(col));
		};

		obj.DelArray=function(name)
		{
			$("#EMH_ENVIRONMENTT_ARRAY").data(name,null);
		};

		obj.GetArrayRow=function(name,row)
		{
			var ooo;
			ooo=$("#EMH_ENVIRONMENTT_ARRAY").data(name);
			if(ooo!=null)
				return ooo.GetArrayRow(row);
		};

		obj.InsArrayRow=function(name,row,data)
		{
			var ooo;
			ooo=$("#EMH_ENVIRONMENTT_ARRAY").data(name);
			if(ooo!=null)
				return ooo.InsArrayRow(row,data);
		};

		obj.DelArrayRow=function(name,row)
		{
			var ooo;
			ooo=$("#EMH_ENVIRONMENTT_ARRAY").data(name);
			if(ooo!=null)
				return ooo.DelArrayRow(row);
		};

		obj.FindArrayRow=function(name,col,text)
		{
			var ooo;
			ooo=$("#EMH_ENVIRONMENTT_ARRAY").data(name);
			if(ooo!=null)
				return ooo.FindArrayRow(col,text);
		};

		obj.GetArrayCell=function(name,row,col)
		{
			var ooo;
			ooo=$("#EMH_ENVIRONMENTT_ARRAY").data(name);
			if(ooo!=null)
				return ooo.GetArrayCell(row,col);
		};

		obj.SetArrayCell=function(name,row,col,text)
		{
			var ooo;
			ooo=$("#EMH_ENVIRONMENTT_ARRAY").data(name);
			if(ooo!=null)
				return ooo.SetArrayCell(row,col,text);
		};

		obj.ArrayFromValue=function(name,valuename)
		{
			return ;
		};

		obj.ArrayToValue=function(name,valuename)
		{
			return ;
		};

		obj.ArrayFromText=function(name,text)
		{
			return ;
		};

		obj.ArrayToText=function(name)
		{
			return ;
		};

		obj.GetArrayRows=function(name)
		{
			var ooo;
			ooo=$("#EMH_ENVIRONMENTT_ARRAY").data(name);
			if(ooo!=null)
				return ooo.GetArrayRows();
		};
		//����XML
		obj.CreateXMLObject=function(name,text)
		{
			return ;
		};

		obj.CloseXMLObject=function(name)
		{
			return ;
		};

		obj.AddXMLItem=function(name,keyname,text,isonly,isobj)
		{
			return ;
		};
		
		obj.DelXMLItem=function(name,keyname,index)
		{
			return ;
		};

		obj.GetXMLItem=function(name,keyname,index)
		{
			return ;
		};

		obj.GetXMLItemTotle=function(name,KeyName,ItemName)
		{
			return ;
		};

		obj.GetXMLObject=function(name,KeyName,SubKeyName,index)
		{
			return ;
		};

		obj.SetXMLObject=function(hd)
		{
			return ;
		};

		obj.SaveXMLObject=function(name,filename)
		{
			return ;
		};

		obj.LoadXMLObject=function(name,filename)
		{
			return ;
		};

		obj.InsertXMLObject=function(name,KeyName,newxml,isonly)
		{
			return ;
		};

		obj.SetValueList=function(name,value,text)
		{
			return ;
		};

		obj.GetValueList=function(name,value)
		{
			return ;
		};

		obj.LockDocment=function(flags)
		{
			return ;
		};
						
		obj.CallEMHCode=function(code)	
		{
			var currentclassobj=this;
			function DebugMessage(message){currentclassobj.DebugMessage(message);};
			function CreatePage(lpname,ww,hh){currentclassobj.CreatePage(lpname,ww,hh);};
			function CreateBox(lppage,lpname,hh,ss){currentclassobj.CreateBox(lppage,lpname,hh,ss);};
			function CreateItem(lppage,lpbox,lpname,ll,tt,ww,hh,ss){currentclassobj.CreateItem(lppage,lpbox,lpname,ll,tt,ww,hh,ss);};
			function OpenPYLayout(operate,name,url){currentclassobj.OpenPYLayout(operate,name,url);};
			function PrintDocname(startpage,direct){currentclassobj.PrintDocname(startpage,direct);};
			function CreateMenu(name,lptext){currentclassobj.CreateMenu(name,lptext);};
			function RunCommand(path){currentclassobj.RunCommand(path);};
			function SelectIME(name){currentclassobj.SelectIME(name);};
			function CreatePopupWindow(title,style,url){currentclassobj.CreatePopupWindow(title,style,url);};
			function ClosePopupWindow(){currentclassobj.ClosePopupWindow();};
			function SetWindowPos(xx,yy){currentclassobj.SetWindowPos(xx,yy);};
			function SetWindowSize(ww,hh){currentclassobj.SetWindowSize(ww,hh);};
			function HIWORD(dd){currentclassobj.HIWORD(dd);};
			function LOWORD(dd){currentclassobj.LOWORD(dd);};
			function atoiStr(dd){currentclassobj.atoiStr(dd);};
			function itoaStr(dd){currentclassobj.itoaStr(dd);};
			function SetValue(nn,dd){ currentclassobj.SetValue(nn, dd);	};
			function SetItemInfo(lppage,lpbox,lpname,ii,lpinfo){ currentclassobj.SetItemInfo(lppage, lpbox, lpname, ii, lpinfo);};
			function GetItemInfo(lppage,lpbox,lpname,ii){ return currentclassobj.GetItemInfo(lppage, lpbox, lpname, ii);};
			function SetJavaValue(lpname,lpinfo){return currentclassobj.SetJavaValue(lpname, lpinfo);};
			function GetJavaValue(lpname){return currentclassobj.GetJavaValue(lpname);};
			function RunUrl(IP,URL,DATA){return currentclassobj.RunUrl(IP, URL, DATA);};
			function PassReturn(rettext,type,para){return currentclassobj.PassReturn(rettext, type, para);};
			function SetTimerEvent(valuename,interval){return currentclassobj.SetTimerEvent(valuename, interval);};
			function SaveDoc(IP,URL,PORT){return currentclassobj.SaveDoc(IP, URL, PORT);};
			function Login(userid,password,url){return currentclassobj.Login(userid, password, url);};
			function Logout(url){return currentclassobj.Logout(url);};
			function ClearDoc(){return currentclassobj.ClearDoc();};
			function UpdatePage(){return currentclassobj.UpdatePage();};
			function GotoParent(){return currentclassobj.GotoParent();};
			function CopyText(text){return currentclassobj.CopyText(text);};
			function SetText(text){return currentclassobj.SetText(text);};
			function GetText(){return currentclassobj.GetText();};
			function RunJS(jstext){return currentclassobj.RunJS(jstext);};
			// ����ĳЩ�?�����û�����ͨ���ά�������佻�����
			function NewArray(name,col){return currentclassobj.NewArray(name, col);};
			function DelArray(name){return currentclassobj.DelArray(name);};
			function GetArrayRow(name,row){return currentclassobj.GetArrayRow(name, row);};
			function InsArrayRow(name,row,data){return currentclassobj.InsArrayRow(name, row, data);};
			function DelArrayRow(name,row){return currentclassobj.DelArrayRow(name,row);};
			function FindArrayRow(name,col,text){return currentclassobj.FindArrayRow(name, col, text);};
			function GetArrayCell(name,row,col){return currentclassobj.GetArrayCell(name, row, col);};
			function SetArrayCell(name,row,col,text){return currentclassobj.SetArrayCell(name, row, col, text);};
			function ArrayFromValue(name,valuename){return currentclassobj.ArrayFromValue(name, valuename);};
			function ArrayToValue(name,valuename){return currentclassobj.ArrayToValue(name, valuename);};
			function ArrayFromText(name,text){return currentclassobj.ArrayFromText(name, text);};
			function ArrayToText(name){return currentclassobj.ArrayToText(name);};
			function GetArrayRows(name){return currentclassobj.GetArrayRows(name);};
			//����XML
			function CreateXMLObject(name,text){return currentclassobj.CreateXMLObject(name, text);};
			function CloseXMLObject(name){return currentclassobj.CloseXMLObject(name);};
			function AddXMLItem(name,keyname,text,isonly,isobj){return currentclassobj.AddXMLItem(name, keyname, text, isonly, isobj);};
			function DelXMLItem(name,keyname,index){return currentclassobj.DelXMLItem(name, keyname, index);};
			function GetXMLItem(name,keyname,index){return currentclassobj.GetXMLItem(name, keyname, index);};
			function GetXMLItemTotle(name,KeyName,ItemName){return currentclassobj.GetXMLItemTotle(name, KeyName, ItemName);};
			function GetXMLObject(name,KeyName,SubKeyName,index){return currentclassobj.GetXMLObject(name, KeyName, SubKeyName, index);};
			function SetXMLObject(hd){return currentclassobj.SetXMLObject(hd);};
			function SaveXMLObject(name,filename){return currentclassobj.SaveXMLObject(name, filename);};
			function LoadXMLObject(name,filename){return currentclassobj.LoadXMLObject(name, filename);};
			function InsertXMLObject(name,KeyName,newxml,isonly){return currentclassobj.InsertXMLObject(name, KeyName, newxml, isonly);};
			function SetValueList(name,value,text){return currentclassobj.SetValueList(name, value, text);};
			function GetValueList(name,value){return currentclassobj.GetValueList(name, value);};
			function LockDocment(flags){return currentclassobj.LockDocment(flags);};
			
			return eval(code);
		};
		/*
		 * ͨ��JS�¼����?��
		 */
		obj.PassEvent=function(eventname)
		{
			
			var selectstr="div.EMHCODE[ENHEVENTNAME='"+eventname+"']";
			if(this.valuename.length>0)
				 selectstr+=("[ENHEVENTVALUE='"+this.valuename+"']");
			var codeobj=$(selectstr);
			if(codeobj.length>0)
			{
				var globalobj=$("div.EMHCODE[ENHEVENTNAME='GLOBALCODELIBARY']");
				if(globalobj.length>0)
					this.CallEMHCode(globalobj.text()+codeobj.text());
				else
					this.CallEMHCode(codeobj.text());
			}
		};
		return obj;
	}
};
//��ʶ���������ʷ�����URL
$(document).ready(
	function()
	{
		$.base64.utf8encode = true;
		$.emhpostobject=EMHEventObject;
		$.emharrayobject=EMHArrayObject;
		jQuery.support.cors = true;
	}
);

